package tuanvn.iti.vn;

import java.util.List;
import java.util.Random;

import mrtran.iti.vn.Main;
import mrtran.iti.vn.Main.GameView;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;

public class SpriteItem {
	private GameView gameView;
	private Bitmap bmp;
	private int  width,height;
	public static int  yItem=(int) (Main.SCREENHEIGHT/1.8);
	public static int xItem;	
	public static int widthLuffyItem,ItemWidth;	
	public static int xItemCenter,yItemCenter;	
	public static int distanceItem;
	private List<SpriteItem> spriteItem;
		
	public SpriteItem(GameView gameView2, Bitmap bmp,List<SpriteItem> spriteItem,float xItem2, float yItem2) {
		this.gameView = gameView2;
		this.bmp = bmp;
		this.height=bmp.getHeight();
		this.width=bmp.getWidth();	
		this.xItem= xItem;
		this.yItem=yItem;
		Random rnd = new Random();
		xItem = rnd.nextInt(gameView.getWidth()-width);
		this.spriteItem = spriteItem;
	}

	private void update() {
		if (distanceItem < widthLuffyItem) {
			if(SpriteHP.mlife!=20){
				SpriteHP.mlife = SpriteHP.mlife + 5;}
			else{}
			spriteItem.remove(this);
			}	

		xItemCenter = (int) (xItem+width/2);
		yItemCenter = (int) (yItem+height/2);
		ItemWidth= width/2;
	}

	public void onDraw(Canvas canvas) {
		update();
		canvas.drawBitmap(bmp, xItem, yItem, null);
	}
}
